#include<iostream>
#include<string>
using namespace std;
class CPU{
	public:

		virtual void calculate() =0;
		virtual ~CPU(){
			cout<<"cpu gouzao"<<endl;
		}
};
class GPU{
	public:

		virtual void video() = 0;
		virtual ~GPU(){

		}
};
class RAM{
	public:

		virtual void process() = 0;
		virtual ~RAM(){

		}
};
class Int:public CPU,public GPU,public RAM{
	public:
		void calculate(){
			cout<<"Int CPU "<<endl;
		}
		void video(){
			cout<<"Int GPU"<<endl;
		}
		void process(){
			cout<<"Int GPU"<<endl;
		}
		~Int(){
			cout<<"Int gouzao"<<endl;
		}

};
class NV:public GPU,public CPU,public RAM{
	public:
		void calculate(){
			cout<<"NV CPU "<<endl;
		}
		void video(){
			cout<<"NV GPU"<<endl;
		}
		void process(){
			cout<<"NV GPU"<<endl;
		}
};
class TSM:public CPU,public GPU,public RAM{
	public:
		void calculate(){
			cout<<"TSM CPU "<<endl;
		}
		void video(){
			cout<<"TSM GPU"<<endl;
		}
		void process(){
			cout<<"TSM GPU"<<endl;
		}
};
class computer{
	public:
		CPU *cpu;
		GPU *gpu;
		RAM *ram;
		computer(CPU *cpu,GPU *gpu,RAM *ram){
			this->cpu = cpu;
			this->gpu = gpu;
			this->ram = ram;

		}
		void makecomputer(){
			cpu->calculate();
			gpu->video();
			ram->process();
		}
		~computer(){
			cout<<"computer gouzao"<<endl;
			if(cpu != NULL){
				delete cpu;
				cpu = NULL;
			}
			if(gpu != NULL){
				delete gpu;
				gpu = NULL;
			}
			if(ram != NULL){
				delete ram;
				ram = NULL;
			}
		}

};

void test01(){
	CPU * Intcpu = new Int;
	GPU * TSMgpu = new TSM;
	RAM * NVram = new NV;
	computer c1(Intcpu,TSMgpu,NVram);
	cout<<"computer1"<<endl;
	c1.makecomputer();
	cout<<"-------------------"<<endl;
	computer *computer2 = new computer(new TSM,new TSM,new TSM);
	cout<<"computer2"<<endl;
	computer2->makecomputer();
	delete computer2;
}
int main(){
	test01();
	return 0;
}




